package com.hidataplus.hadoop.tezui;

import java.util.Properties;
import java.io.InputStream;
import java.io.IOException;

public class Config {


    private static String yarnAtsUrl = "";
    private static String yarnRmUrl = "";
    private static Boolean kerberosEnable = false;
    private static Boolean kerberosDebug = false;
    private static String kerberosPrincipal = "";
    private static String kerberosKeytab = "";
    private static String kerberosKrb5conf = "";
    private static String userName = "";
    private static String userAdmin = "";
    private static String userLoginTye = "";
    private static String userLoginLdapUrl = "";
    private static String userLoginLdapUserNameRegex = "";

    private static Boolean userPermissionPageCheck = false;
    private static Boolean proxyKnoxEnable = false;
//    private static String proxyOriginKeywords = "";
    private static String proxyKnoxUrl = "";



    static {
        Properties prop = new Properties();
//        Config.class.getResourceAsStream("/XXX.properties");
        InputStream in = Config.class.getResourceAsStream("/config.properties");
        try {
            prop.load(in);
            yarnAtsUrl = prop.getProperty("yarn.ats.url").trim();
            yarnRmUrl = prop.getProperty("yarn.rm.url").trim();
            kerberosEnable = Boolean.parseBoolean(prop.getProperty("kerberos.enable"));
            kerberosDebug = Boolean.parseBoolean(prop.getProperty("kerberos.debug"));
            kerberosPrincipal = prop.getProperty("kerberos.principal").trim();
            kerberosKeytab = prop.getProperty("kerberos.keytab").trim();
            kerberosKrb5conf = prop.getProperty("kerberos.krb5conf").trim();
            userName = prop.getProperty("user.name").trim();
            userAdmin = prop.getProperty("user.admin").trim();
            userLoginTye = prop.getProperty("user.login.type").trim();
            userLoginLdapUrl = prop.getProperty("user.login.ldap.url").trim();
            userLoginLdapUserNameRegex = prop.getProperty("user.login.ldap.userNameRegx").trim();

            proxyKnoxUrl = prop.getProperty("proxy.knox.url").trim();
            proxyKnoxEnable = Boolean.parseBoolean(prop.getProperty("proxy.knox.enable"));
//            proxyOriginKeywords = prop.getProperty("proxy.knox.origin.keywords").trim();

            userPermissionPageCheck = Boolean.parseBoolean(prop.getProperty("user.permission.page.check"));



        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 私有构造方法，不需要创建对象
     */
    private Config() {
    }

    public static String getYarnAtsUrl() {
        return yarnAtsUrl;
    }

    public static String getYarnRmUrl() {
        return yarnRmUrl;
    }

    public static Boolean getKerberosEnable() {
        return kerberosEnable;
    }

    public static String getKerberosPrincipal() {
        return kerberosPrincipal;
    }

    public static String getKerberosKeytab() {
        return kerberosKeytab;
    }

    public static String getKerberosKrb5conf() {
        return kerberosKrb5conf;
    }

    public static Boolean getKerberosDebug() {
        return kerberosDebug;
    }

    public static String getUserName() {
        return userName;
    }

    public static String getUserAdmin() {
        return userAdmin;
    }

    public static String getUserLoginTye() { return userLoginTye;   }

    public static String getUserLoginLdapUrl() {
        return userLoginLdapUrl;
    }

    public static String getUserLoginLdapUserNameRegex() {
        return userLoginLdapUserNameRegex;
    }


//    public static String getProxyOrginUrls() {
//        return proxyOrginUrls;
//    }
    public static String getProxyKnoxUrl() {
        return proxyKnoxUrl;
    }

    public static Boolean getProxyKnoxEnable() {
        return proxyKnoxEnable;
    }

//    public static String getProxyOriginKeywords() {
//        return proxyOriginKeywords;
//    }


    public static Boolean getUserPermissionPageCheck() {
        return userPermissionPageCheck;
    }

    public static void main(String args[]){
        System.out.println(getYarnAtsUrl());
        System.out.println(getYarnRmUrl());
    }

}
